package com.javaziliao.design.dprecated.state;


import com.javaziliao.design.dprecated.DeprecatedConstants;
import com.javaziliao.design.dprecated.observer.DeprecatedAbstractObserver;

import java.util.List;
import java.util.Vector;

public abstract class DeprecatedAbstractOrderState {
    public static final String ORDER_WAIT_PAY = "ORDER_WAIT_PAY";// 待支付
    public static final String ORDER_WAIT_SEND = "ORDER_WAIT_SEND";// 待发货
    public static final String ORDER_WAIT_RECEIVE = "ORDER_WAIT_RECEIVE";// 待收货
    public static final String ORDER_FINISH = "ORDER_FINISH";// 订单完成

    // 关联抽象观察者
    protected final List<DeprecatedAbstractObserver> observerList = DeprecatedConstants.OBSERVER_LIST;

    public void addObserver(DeprecatedAbstractObserver observer) {
        this.observerList.add(observer);
    }

    public void removeObserver(DeprecatedAbstractObserver observer) {
        this.observerList.remove(observer);
    }

    // 通知观察者进行相关操作（调用orderStateHandle方法）
    public void notifyObserver(String orderId,String orderState){
        for (DeprecatedAbstractObserver observer : this.observerList) {
            observer.orderStateHandle(orderId,orderState);
        }
    }

    // 创建订单
    public DeprecatedOrder createOrder(String orderId, String productId, DeprecatedOrderContext context) {
        throw new UnsupportedOperationException();
    }

    // 订单支付
    public DeprecatedOrder payOrder(String orderId, DeprecatedOrderContext context) {
        throw new UnsupportedOperationException();
    }

    // 订单发送
    public DeprecatedOrder sendOrder(String orderId, DeprecatedOrderContext context) {
        throw new UnsupportedOperationException();
    }

    // 订单签收
    public DeprecatedOrder receiveOrder(String orderId, DeprecatedOrderContext context) {
        throw new UnsupportedOperationException();
    }

}
